<template>
 <el-upload
  action="http://localhost:8889/upVideoImg" 
  :before-upload="beforeAvatarUpload"

  :on-success="handleAvatarSuccess"
  name="myFile"

 >
  影图上传
</el-upload>
</template>
<script>
import connect from './connect';
  export default {
 
    data() {
      return {
     //注意先传图片后传视频  顺序不能乱
      };
    },
    methods: {
        handleAvatarSuccess(res,file) {
        this.imageUrl = URL.createObjectURL(file.raw);
        // console.log(file.response)
        // console.log(typeof file.response)
        // console.log(file.response)
        this.$store.dispatch("imgSrc",file.response)
      
      
      
   
       
         
      }
      
     ,

        beforeAvatarUpload(file) {
       
       
        const isJPG = file.type === 'image/jpeg';
        const isLt2M = file.size / 1024 / 1024 < 2;

        if (!isJPG) {
          this.$message.error('上传头像图片只能是 JPG 格式!');
        }
        if (!isLt2M) {
          this.$message.error('上传头像图片大小不能超过 2MB!');
        }
     
        return isJPG && isLt2M;
      }

    }
  }
</script>